function fnSleep(addTime, userId, friendId, token) { //初始化
	sleepDate(addTime, userId, friendId, token);
}

//接口
function sleepDate(addTime, userId, friendId, token) { //睡眠
	var url = "http://api.sungohealth.com/sleep/data";
	var data = {
		addTime: addTime,
		userId: userId,
		friendId: friendId,
		token: token
	};
	$.ajax({
		type: "POST",
		url: url,
		data: data,
		dataType: "json",
		success: function(data, status, xhr) {
			console.log(data);
			if(data.status == '0' || data.msg == '成功') {
				$('.unEmpty').removeClass('dn');
				$('.empty').addClass('dn');
				fn_option_sleep(addTime, data.data); //数据渲染
			} else {
				$('.unEmpty').addClass('dn');
				$('.empty').removeClass('dn');
			}
		},
		error: function(result) {
			console.log(result);
		}
	});
}

//接口测试数据
///*var dataTemp = {
//  "status": 0,
//  "msg": "成功",
//  "data": {
//      "sleepId": 1,
//      "userId": 1,
//      "dateData": "2018-03-23",
//      /*"sleepData":'[' +
//      '["2018-04-29 00:22:53","2018-04-29 01:12:53","1"], ' +
//      '["2018-04-29 01:12:53","2018-04-29 01:42:53","2"],' +
//      '["2018-04-29 01:42:53","2018-04-29 02:02:53","0"], ' +
//      '["2018-04-29 02:02:53","2018-04-29 02:32:53","2"], ' +
//      '["2018-04-29 02:32:53","2018-04-29 02:52:53","1"], ' +
//      '["2018-04-29 02:52:53","2018-04-29 03:22:53","0"], ' +
//      '["2018-04-29 03:22:54","2018-04-29 04:12:54","2"], ' +
//      '["2018-04-29 04:12:54","2018-04-29 04:32:54","1"], ' +
//      '["2018-04-29 04:32:54","2018-04-29 04:52:54","2"], ' +
//      '["2018-04-29 04:52:54","2018-04-29 05:32:54","1"], ' +
//      '["2018-04-29 05:32:54","2018-04-29 05:52:54","0"], ' +
//      '["2018-04-29 05:52:54","2018-04-29 06:32:54","1"], ' +
//      '["2018-04-29 06:32:54","2018-04-29 07:02:54","2"], ' +
//      '["2018-04-29 07:02:54","2018-04-29 07:32:54","1"], ' +
//      '["2018-04-29 07:32:54","2018-04-29 08:12:54","2"], ' +
//      '["2018-04-29 08:12:55","2018-04-29 08:32:55","1"], ' +
//      '["2018-04-29 08:32:55","2018-04-29 09:02:55","0"], ' +
//      '["2018-04-29 09:02:55","2018-04-29 09:12:55","1"], ' +
//      '["2018-04-29 09:12:51","2018-04-29 09:22:51","0"]]',*/
//       "sleepData":'[["2018-05-11 00:26:00","2018-05-11 01:46:00","2"],["2018-05-11 05:06:00","2018-05-11 05:36:00","2"],["2018-05-11 05:36:00","2018-05-11 06:30:00","1"]]',
//
//      /*"sleepData":'' +
//      '[["2018-05-10 01:10:41","2018-05-10 01:40:41","2"],' +
//      '["2018-05-10 01:40:42","2018-05-10 02:00:42","1"],' +
//      '["2018-05-10 02:00:42","2018-05-10 02:40:42","2"],' +
//      '["2018-05-10 02:40:42","2018-05-10 03:40:42","1"],' +
//      '["2018-05-10 03:40:42","2018-05-10 04:10:42","2"],' +
//      '["2018-05-10 04:10:42","2018-05-10 04:30:42","1"],' +
//      '["2018-05-10 04:30:43","2018-05-10 05:30:43","2"],' +
//      '["2018-05-10 05:30:43","2018-05-10 07:30:43","1"],' +
//      '["2018-05-10 07:30:43","2018-05-10 07:50:43","0"],' +
//      '["2018-05-10 07:50:43","2018-05-10 08:30:43","1"],' +
//      '["2018-05-10 08:30:43","2018-05-10 08:51:43","0"]]',*///最后100.00000000000001  必须是100
//
//      //2018-02-07 08:29:52  527//总和
//      //2018-02-07 08:02:52  500//总和
//
//       "hrSleepData": "[{\"05:24:51\":62},{\"05:34:51\":61},{\"05:44:51\":65},{\"05:54:51\":66}]",
//      "hrSleepData": '[{"00:08:53":"85"},{"00:18:53":"82"},{"00:28:54":"78"},{"00:48:54":"98"},{"00:58:54":"94"},{"01:08:54":"84"},{"01:18:54":""},{"01:28:54":""},{"01:38:54":"93"},{"01:48:54":"80"},{"01:58:54":"84"},{"02:08:55":"72"},{"02:18:55":"73"},{"02:28:55":"81"},{"02:38:55":"77"},{"02:48:55":"78"},{"02:58:55":"76"},{"03:08:55":"77"},{"03:18:55":"75"},{"03:28:55":"72"},{"03:38:55":"82"},{"03:48:56":"76"},{"03:58:56":"78"},{"04:18:56":"76"},{"04:38:56":"83"},{"04:48:56":"74"},{"04:58:56":"71"},{"05:08:56":"60"},{"05:18:56":"71"},{"05:28:56":"74"},{"05:38:56":"62"},{"05:48:57":"81"},{"05:58:57":"59"},{"06:08:57":"62"},{"06:18:57":"59"},{"06:28:57":"56"},{"06:38:57":"61"},{"06:48:57":"65"},{"06:58:57":"105"},{"07:08:57":"61"},{"07:18:57":"72"},{"07:28:58":"75"},{"07:38:58":"74"},{"07:48:58":"63"},{"07:58:58":"59"},{"08:08:58":"64"},{"08:18:58":"75"},{"08:28:58":"64"},{"08:58:58":"110"},{"09:08:58":"110"},{"09:18:58":"91"},{"09:28:59":"106"},{"09:38:59":"87"},{"09:48:59":"79"},{"09:58:59":"81"},{"10:08:59":"89"},{"10:18:59":"109"},{"10:38:59":"77"},{"10:48:59":"92"},{"10:58:59":"90"},{"11:08:59":"81"},{"11:18:00":"73"},{"11:28:28":"76"},{"11:38:29":"83"},{"11:48:29":"77"},{"11:58:35":"72"}]',
//      "scoreTime": "4.5",
//      "scoreDuration": "3.5",
//      "scoreQuality": "2.5",
//      "scoreSpeed": "1.5",
//      "sleepCode": "多运动，适当增强有氧运动建议您在10:30前入睡.................",
//      "deepSleep": "4小时10分钟",
//      "lightSleep": "4小时10分钟",
//      "exception": "0小时10分钟",
//      "updateTime": "04:01:55",
//      "addTime": 1521802181000,
//      "status": "processed",
//      "arrayList": [ { "deep_sleep": "4小时10分钟", "exception": "0小时10分钟", "update_time": "04:01:55", "sleep_id": 1, "date_data": "2018-03-23", "light_sleep": "4小时10分钟", "all_sleep": "8小时30分钟" } ]
//  }
//};
// fn_option('2018-04-03',dataTemp.data);

function fn_option_sleep(time, data) {
	//	 $('.unEmpty').removeClass('dn');$('.empty').addClass('dn');

	//页面展示信息
	//评星
	star_sun('.sleep_star0', data.scoreTime); //睡眠时间
	star_sun('.sleep_star1', data.scoreDuration); //睡眠时长
	star_sun('.sleep_star2', data.scoreQuality); //睡眠质量
	star_sun('.sleep_star3', data.scoreSpeed); //入睡速度

	$(".olState_sm li").html(data.sleepCode); //睡眠状态提示

	//运动状态和心率统计
	if(data.deepSleep) {
		$(".sleep0_1").html(data.deepSleep.split('小时')[0]);
	} //深睡
	if(data.deepSleep) {
		$(".sleep0_2").html(data.deepSleep.split('小时')[1].split('分钟')[0]);
	} //深睡
	if(data.lightSleep) {
		$(".sleep0_3").html(data.lightSleep.split('小时')[0]);
	} //浅睡
	if(data.lightSleep) {
		$(".sleep0_4").html(data.lightSleep.split('小时')[1].split('分钟')[0]);
	} //浅睡
	if(data.exception) {
		$(".sleep0_5").html(data.exception.split('小时')[0]);
	} //异常
	if(data.exception) {
		$(".sleep0_6").html(data.exception.split('小时')[1].split('分钟')[0]);
	} //异常

	//睡眠
	var sleepData = JSON.parse(data.sleepData); //睡眠
	var hrSleepData = JSON.parse(data.hrSleepData); //心率

	//睡眠 - 深睡/浅睡/异常
	var len = 0; //深睡/浅睡/异常的时间段长度
	var sleep_data2 = [];
	var sleep_h = [40, 60, 80];
	var sleep_s = ['A', 'B', 'C'];
	if(sleepData) {

		var tm = sleepData[0][0];
		tm = tm.replace(/-/g, ':').replace(' ', ':');
		tm = tm.split(':');
		var tm1 = sleepData[sleepData.length - 1][1];
		tm1 = tm1.replace(/-/g, ':').replace(' ', ':');
		tm1 = tm1.split(':');

		// var start_time = new Date(sleepData[0][0]).getTime();//开始时间的时间戳
		// var end_time = new Date(sleepData[sleepData.length-1][1]).getTime();//结束时间的时间戳
		var start_time = new Date(tm[0], (tm[1] - 1), tm[2], tm[3], tm[4], tm[5]).getTime(); //开始时间的时间戳
		var end_time = new Date(tm1[0], (tm1[1] - 1), tm1[2], tm1[3], tm1[4], tm1[5]).getTime(); //结束时间的时间戳
		var len_time = Math.round((end_time - start_time) / 60000); //总的时间段(分钟数)
		//睡眠 - 心率
		var uesHourTemp_sleep = []; //x轴列表
		var len_time_sub = Math.round(len_time / 10); //x轴长度，根据睡眠时长来确定
		var t_s_h = sleepData[0][0].split(' ')[1].split(':')[0]; //开始时间小时
		var t_s_m = sleepData[0][0].split(' ')[1].split(':')[1]; //开始时间分钟
		var t_e_h = sleepData[sleepData.length - 1][1].split(' ')[1].split(':')[0]; //结束时间小时
		var t_e_m = sleepData[sleepData.length - 1][1].split(' ')[1].split(':')[1]; //结束时间分钟

	}

	var tempList = [];
	tempList[0] = Math.floor(t_s_h * 60) + Math.floor(t_s_m);
	for(var i = 1; i < len_time_sub; i++) { //超过1440就是第二天
		var temp = tempList[i - 1]; //需要定义一个变量
		if(temp > 1430) {
			temp = temp - 1440;
		}
		tempList[i] = temp + 10;
	}
	var sleepTxt = [];

	if(sleepData) {
		$.each(tempList, function(key, val) { //时间数据比对，生成echart需要数据
			$.each(sleepData, function(k, v) { //睡眠 - 心率
				var t = v[0].split(' ')[1].split(':');
				var minutesTemp = Math.floor(t[0] * 60) + Math.floor(t[1]);
				var l0 = v[0].split(' ')[1].split(':');
				var l1 = v[1].split(' ')[1].split(':');
				var str = l0[0] + ':' + l0[1] + '-' + l1[0] + ':' + l1[1];
				if(Math.abs(minutesTemp - val) <= 5) { //小于等于5
					sleepTxt[key] = [];
					if(v[2] == 2) {
						sleepTxt[key][0] = '深睡';
					} else if(v[2] == 1) {
						sleepTxt[key][0] = '浅睡';
					} else if(v[2] == 0) {
						sleepTxt[key][0] = '异常';
					} else {
						sleepTxt[key][0] = '数据异常';
					}
					sleepTxt[key][1] = str;
				}
			});
		});
		if(sleepTxt.length < len_time_sub) {
			sleepTxt[len_time_sub - 1] = '';
		}
		$.each(sleepTxt, function(key, val) {
			if(!val) {
				sleepTxt[key] = sleepTxt[key - 1];
			}
		});
	}

	var sleep_data1 = []; //心率
	var sleep_data1_txt = []; //心率文字
	var hourTemp_sleep = []; //心率时间列表
	if(hrSleepData) {
		$.each(tempList, function(key, val) { //时间数据比对，生成echart需要数据
			$.each(hrSleepData, function(k, v) { //睡眠 - 心率
				$.each(v, function(m, n) {
					var minutesTemp = Math.floor(m.split(':')[0] * 60) + Math.floor(m.split(':')[1]);
					if(Math.abs(minutesTemp - val) <= 5) { //小于等于5
						sleep_data1[key] = n;
						sleep_data1_txt[key] = n;
						hourTemp_sleep[key] = m;
					}
				});
			});
		});
		if(sleep_data1.length < len_time_sub) {
			sleep_data1[len_time_sub - 1] = '';
		} //不足量的时候填补空白
		if(hourTemp_sleep.length < len_time_sub) {
			hourTemp_sleep[len_time_sub - 1] = '';
		}

		if(sleep_data1_txt.length < len_time_sub) {
			sleep_data1_txt[len_time_sub - 1] = '';
		}

		// console.log(sleep_data1);
		// console.log(sleep_data1_txt);
		// console.log(hourTemp_sleep);
	}

	// console.log(sleep_data1);
	/*if(sleep_data1){//补缺失1位的不足
	    $.each(sleep_data1, function(key, val) {//心率
	        if(!val && sleep_data1[key-1] && sleep_data1[key+1]){
	            sleep_data1[key] = (parseInt(sleep_data1[key-1])+parseInt(sleep_data1[key+1]))/2
	        }
	    });
	}*/
	if(sleep_data1) { //补缺失2位以及以下的不足
		$.each(sleep_data1, function(key, val) { //心率
			if(!val && sleep_data1[key - 1] && sleep_data1[key + 1]) { //缺一位
				sleep_data1[key] = (parseInt(sleep_data1[key - 1]) + parseInt(sleep_data1[key + 1])) / 2
			} else if(!val && sleep_data1[key - 1] && sleep_data1[key + 2]) { //缺两位
				sleep_data1[key] = (parseInt(sleep_data1[key - 1]) + parseInt(sleep_data1[key + 2])) / 2;
				sleep_data1[key + 1] = (parseInt(sleep_data1[key - 1]) + parseInt(sleep_data1[key + 2])) / 2;
			}
		});
	}

	if(uesHourTemp_sleep) {
		uesHourTemp_sleep[0] = t_s_h + ':' + t_s_m;
		uesHourTemp_sleep[len_time_sub - 1] = t_e_h + ':' + t_e_m;
		for(var i = 1; i < len_time_sub - 1; i++) {
			uesHourTemp_sleep[i] = '';
		}
		var num_interval = len_time_sub - 2;
	}

	if(sleepData) {
		$.each(sleepData, function(key, val) {

			// 时间戳处理
			var tm2 = val[0];
			tm2 = tm2.replace(/-/g, ':').replace(' ', ':');
			tm2 = tm2.split(':');
			var tm3 = val[1];
			tm3 = tm3.replace(/-/g, ':').replace(' ', ':');
			tm3 = tm3.split(':');

			var time0 = new Date(tm2[0], (tm2[1] - 1), tm2[2], tm2[3], tm2[4], tm2[5]).getTime();
			var time1 = new Date(tm3[0], (tm3[1] - 1), tm3[2], tm3[3], tm3[4], tm3[5]).getTime();
			// var time = Math.floor((time1-time0)/60000/len_time*100);
			//四舍五入之后并不能保证一定是100%
			// 每个时间段的百分比
			var time = (time1 - time0) / 60000 / len_time * 100; //每个时间段的百分比
			sleep_data2[key] = [];
			sleep_data2[key][0] = len;
			len += time;
			sleep_data2[key][1] = len;
			if(val[2] == 2) {
				sleep_data2[key][2] = sleep_h[0];
				sleep_data2[key][3] = sleep_s[0];
			} else if(val[2] == 1) {
				sleep_data2[key][2] = sleep_h[1];
				sleep_data2[key][3] = sleep_s[1];
			} else if(val[2] == 0) {
				sleep_data2[key][2] = sleep_h[2];
				sleep_data2[key][3] = sleep_s[2];
			}
		});

		sleep_data2[sleep_data2.length - 1][1] = 100; //强制定为100
		// console.log(sleep_data2);

	}

	//数据处理
	var last16 = dayList(time).last16; //日期
	var dataTemp = dayList(time).ecShow; //echart日期
	var uesTemp = dayList(time).ecUse; //echart日期下标

	//睡眠-数据
	var sleep2_data1 = [],
		sleep2_data2 = [],
		sleep2_data1_show = [],
		sleep2_data2_show = [];
	var data_arr1 = data.arrayList;
	if(data_arr1) {
		$.each(last16, function(key, val) { //日期数据比对，生成echart需要数据
			$.each(data_arr1, function(k, v) { //睡眠趋势分析
				if(val == v.date_data) {
					var deep0 = v.deep_sleep.split('小时')[0];
					var deep1 = v.deep_sleep.split('小时')[1].split('分钟')[0];
					var deep = parseInt(deep0) + parseFloat(deep1/60);
					var all0 = v.all_sleep.split('小时')[0];
					var all1 = v.all_sleep.split('小时')[1].split('分钟')[0];
					var all = parseInt(all0) + parseFloat(all1 / 60);
					sleep2_data1[key] = deep;
					sleep2_data2[key] = all - deep;
					sleep2_data1_show[key] = v.deep_sleep;
					sleep2_data2_show[key] = v.all_sleep;
				}
			});
		});
		if(sleep2_data1.length < 16) {
			sleep2_data1[15] = '';
		} //数组不足16个时
		if(sleep2_data2.length < 16) {
			sleep2_data2[15] = '';
		}
		if(sleep2_data1_show.length < 16) {
			sleep2_data1_show[15] = '';
		}
		if(sleep2_data2_show.length < 16) {
			sleep2_data2_show[15] = '';
		}
	}

	// 睡眠
	var option_sleep1 = {
		grid: {
			y: 50,
			x2: 28,
			y2: 30,
			x: 46
		},
		tooltip: { // 提示框
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 120, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemp = hourTemp_sleep[params[0].dataIndex];
				var timeTemp_txt = sleep_data1_txt[params[0].dataIndex];
				var sleepTemp = sleepTxt[params[0].dataIndex][0] + '：' + sleepTxt[params[0].dataIndex][1];
				if(!timeTemp) {
					timeTemp = '--:--:--'
				}
				var res = '<div><p>时间：' + timeTemp + '</p>'
				for(var i = 0; i < params.length; i++) {
					if(i == 0) {
						if(timeTemp_txt) {
							res += '<p>心率：' + timeTemp_txt + '</p>'
						} else {
							res += '<p>心率：---</p>'
						}
					}
				}
				res += '<p>' + sleepTemp + '</p>'
				res += '</div>';
				return res;
			},
		},
		xAxis: {
			type: 'category',
			boundaryGap: false,
			data: uesHourTemp_sleep,
			axisLabel: {
				interval: num_interval,
				textStyle: {
					color: '#999',
					fontSize: '8'
				}
			},
			axisLine: {
				show: false,
				lineStyle: {
					color: '#e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: {
			scale: true,
			max: 140,
			min: 0,
			splitNumber: 6,
			type: 'value',
			axisLabel: {
				show: true,
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: false,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		series: [{
			name: '心率',
			type: 'line',
			smooth: true,
			data: sleep_data1,
			symbol: 'null',
			symbolSize: 0,
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#fd7b52'
					}
				}
			},
		}],
	};

	var option_sleep2 = {
		grid: {
			y: 50,
			x2: 14,
			y2: 30,
			x: 50,
		},
		tooltip: {
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 120, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容

				var deep_show = sleep2_data1_show[params[0].dataIndex];
				var all_show = sleep2_data2_show[params[0].dataIndex];

				var timeTemp = dataTemp[params[0].dataIndex].split('/');
				var timeShow = timeTemp[0] + '月' + timeTemp[1] + '日';
				var res = '<div class="tooltip"><p>' + timeShow + '</p>'
				for(var i = 0; i < params.length; i++) {
					if(i == 0) {
						if(params[i].data) {
							res += '<p class="p_13">深睡 ' + deep_show + '</p>'
						} else {
							res += '<p class="p_13">深睡 ---</p>'
						}
					} else if(i == 1) {
						if(params[i].data) {
							res += '<p class="p_86">总长 ' + all_show + '</p>'
						} else {
							res += '<p class="p_86">总长 ---</p>'
						}
					}
				}
				res += '</div>';
				return res;
			},
		},
		xAxis: {
			type: 'category',
			data: uesTemp,
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false
			}
		},
		yAxis: {
			// scale: true, min: 0, splitNumber: 5, type: 'value',
			scale: true,
			min: 0,
			interval: 1,
			type: 'value',
			// axisLabel: {show: true, formatter: '{value}小时', textStyle: {color: '#999'}},
			axisLabel: {
				show: true,
				formatter: function(value) {
					// Function formatter
					//return value / 60;
					return value;
				},
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		color: ['#86d9e0', '#13b5b1'],
		legend: { //图例
			selectedMode: false,
			x: 'left',
			padding: [0, 0, 0, 35],
			itemWidth: 15,
			itemHeight: 6,
			itemGap: 27,
			data: [{
				name: '总长',
				icon: 'rect',
			}, {
				name: '深睡',
				icon: 'rect'
			}],
		},
		series: [{ //数据
			name: '深睡',
			type: 'bar',
			stack: '步数',
			barWidth: 6,
			data: sleep2_data1,
			itemStyle: {
				normal: {
					color: '#13b5b1'
				}
			},
		}, {
			name: '总长',
			type: 'bar',
			stack: '步数',
			barWidth: 6,
			data: sleep2_data2,
			itemStyle: {
				normal: {
					color: '#86d9e0'
				}
			},
		}, ],
	};
	echarts.init(document.getElementById("sleep0")).setOption(option_sleep1, true);
	echarts.init(document.getElementById("sleep1")).setOption(option_sleep2, true);

	sleep(sleep_data2);
}

function sleep(sleep_data) {

	var data = sleep_data; //睡眠数据
	var colorList = ['#86d9e0', '#0091ea', '#cfa972'];
	data = echarts.util.map(data, function(item, index) { //添加颜色
		var color;
		if(item[2] == 60) {
			color = colorList[0];
		} else if(item[2] == 40) {
			color = colorList[1];
		} else if(item[2] == 80) {
			color = colorList[2];
		}
		return {
			value: item,
			itemStyle: {
				normal: {
					color: color
				}
			} //颜色
		};
	});

	function renderItem(params, api) {
		var yValue = api.value(2);
		var start = api.coord([api.value(0), yValue]);
		var size = api.size([api.value(1) - api.value(0), yValue]);
		var style = api.style();
		return {
			type: 'rect',
			shape: {
				x: start[0],
				y: start[1],
				width: size[0],
				height: size[1]
			},
			style: style
		};
	};
	var option_sleep3 = {
		grid: {
			y: 50,
			x2: 28,
			y2: 30,
			x: 46,
		},
		tooltip: {
			show: false
		},
		xAxis: {
			scale: true,
			axisLabel: {
				show: false
			},
			splitLine: {
				show: false
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false
			}
		},
		yAxis: {
			max: 140,
			min: 0,
			splitNumber: 6,
			axisLabel: {
				show: false
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		series: [{
			type: 'custom',
			renderItem: renderItem,
			dimensions: ['from', 'to', 'profit'],
			encode: {
				x: [0, 1],
				y: 2,
				tooltip: [0, 1, 2],
				itemName: 3
			},
			data: data
		}]
	};
	echarts.init(document.getElementById("sleep3")).setOption(option_sleep3, true);
}

/*
[
    ["2018-04-29 00:22:53","2018-04-29 01:12:53","1"],
    ["2018-04-29 01:12:53","2018-04-29 01:42:53","2"],
    ["2018-04-29 01:42:53","2018-04-29 02:02:53","0"],
    ["2018-04-29 02:02:53","2018-04-29 02:32:53","2"],
    ["2018-04-29 02:32:53","2018-04-29 02:52:53","1"],
    ["2018-04-29 02:52:53","2018-04-29 03:22:53","3"],
    ["2018-04-29 03:22:54","2018-04-29 04:12:54","2"],
    ["2018-04-29 04:12:54","2018-04-29 04:32:54","1"],
    ["2018-04-29 04:32:54","2018-04-29 04:52:54","2"],
    ["2018-04-29 04:52:54","2018-04-29 05:32:54","1"],
    ["2018-04-29 05:32:54","2018-04-29 05:52:54","0"],
    ["2018-04-29 05:52:54","2018-04-29 06:32:54","1"],
    ["2018-04-29 06:32:54","2018-04-29 07:02:54","2"],
    ["2018-04-29 07:02:54","2018-04-29 07:32:54","1"],
    ["2018-04-29 07:32:54","2018-04-29 08:12:54","2"],
    ["2018-04-29 08:12:55","2018-04-29 08:32:55","1"],
    ["2018-04-29 08:32:55","2018-04-29 09:02:55","0"],
    ["2018-04-29 09:02:55","2018-04-29 09:12:55","1"],
    ["2018-4-29 09:12:51","2018-4-29 09:22:51","1"]
]*/